//
//  parametersTableViewCell.m
//  YiFei
//
//  Created by yangyan on 16/8/31.
//  Copyright © 2016年 yous. All rights reserved.
//

#import "parametersTableViewCell.h"

@implementation parametersTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}


-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self=[super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self addView];
        [self addView2];
        [self addContentView];
        [self addContentView2];
    }
    return self;
}

-(void)addView{
    _titleA=[NSMutableArray arrayWithObjects:@"公司货号",@"规格",@"报价日期",@"颜色",@"价格条款",@"材质",@"尺寸",@"商品备注", nil];
    _viewback=[[UIView alloc] init];
    [_viewback sizeToFit];
    _viewback.backgroundColor=[UIColor whiteColor];
    _viewback.layer.masksToBounds=YES;
    _viewback.layer.cornerRadius=5.0;
    _viewback.frame=CGRectMake(10, 0, WIDTH-20, _titleA.count*30);
    [self.contentView addSubview:_viewback];
    for (int i=0; i<_titleA.count; i++) {
        UIView *view=[[UIView alloc] init];
        [view sizeToFit];
        view.frame=CGRectMake(i%2*(WIDTH - 30)/2.0 + i%2*5, i/2*30, (WIDTH - 30)/2.0, 30);
        [_viewback addSubview:view];
        UILabel *labelL=[[UILabel alloc] init];
        [labelL sizeToFit];
        labelL.text=_titleA[i];
        labelL.textColor=[UIColor lightGrayColor];
        labelL.font=[UIFont systemFontOfSize:12.0];
        labelL.frame=CGRectMake(5, 0, (WIDTH-80)/4, 30);
        [view addSubview:labelL];
    }
}

-(void)addView2{
    for (int i=0; i<_titleA.count; i++) {
        UIView *view=[[UIView alloc] init];
        [view sizeToFit];
        view.frame=CGRectMake(i%2*(WIDTH - 30)/2.0 + i%2*5, i/2*30, (WIDTH - 30)/2.0, 30);
        [_viewback addSubview:view];
        
        _lableL=[[UILabel alloc] init];
        [_lableL sizeToFit];
        _lableL.font=[UIFont systemFontOfSize:12.0];
        _lableL.textColor=[UIColor blackColor];
        _lableL.tag=30+i;
        _lableL.frame=CGRectMake((WIDTH-80)/4+5, 0, (WIDTH-30)/2-(WIDTH-80)/4, 30);
        [view addSubview:_lableL];
    }
}



-(void)setShopObj:(shopData *)shopObj{
    for (int i=0;i<_titleA.count;i++) {
        UILabel *lable=[self.contentView viewWithTag:30+i];
        switch (lable.tag) {
            case 30:
            {if (shopObj.companyID == 0) {
                shopObj.companyID = 0;
                lable.text = shopObj.shopMed;
            }else{
                lable.text = shopObj.shopMed;
            }
            }
                break;
            case 31:
            {if (shopObj.shopSize.length == 0) {
                shopObj.shopSize = 0;
                lable.text = shopObj.shopSize;
            }else{
                lable.text = shopObj.shopSize;
            }
            }
                lable.text=shopObj.shopSize;
                break;
                
            case 32:
                lable.text=shopObj.shopSize;
                break;
                
            case 33:
                lable.text=shopObj.shopColor;
                break;
                
            case 34:
                lable.text=shopObj.shopTiaoK;
                break;
                
            case 35:
                lable.text=shopObj.shopMed;
                break;

            case 36:
                lable.text=shopObj.shopSize;
                break;
                
            case 37:
                lable.text=shopObj.shopDescribe;
                break;
                
            default:
                break;
        }

    }
    _shopObj=shopObj;
    
    
    NSString *str=[NSString stringWithFormat:@"%@",_shopObj.shopCustom];
    _leftArray=[str componentsSeparatedByString:@"|"];
    NSString *str2=[NSString stringWithFormat:@"%@",_shopObj.shopContent];
    _rightArray=[str2 componentsSeparatedByString:@"|"];
    [self addContentView];
    [self addContentView2];
}

-(void)addContentView{
    _viewback2=[[UIView alloc] init];
    [_viewback2 sizeToFit];
    _viewback2.backgroundColor=[UIColor whiteColor];
    _viewback2.layer.masksToBounds=YES;
    _viewback2.layer.cornerRadius=5.0;
    _viewback2.frame=CGRectMake(10, 120, WIDTH-20, _leftArray.count*30);
    [self.contentView addSubview:_viewback2];
    for (int i=0; i<_leftArray.count; i++) {
        UIView *view=[[UIView alloc] init];
        [view sizeToFit];
        view.frame=CGRectMake(i%2*(WIDTH - 30)/2.0 + i%2*5, i/2*30, (WIDTH - 30)/2.0, 30);
        [_viewback2 addSubview:view];
        UILabel *labelL=[[UILabel alloc] init];
        [labelL sizeToFit];
        labelL.text=_leftArray[i];
        labelL.textColor=[UIColor lightGrayColor];
        labelL.font=[UIFont systemFontOfSize:12.0];
        labelL.frame=CGRectMake(5, 0, (WIDTH-80)/4, 30);
        [view addSubview:labelL];
    }
}


-(void)addContentView2{
    for (int i=0; i<_rightArray.count; i++) {
        UIView *view=[[UIView alloc] init];
        [view sizeToFit];
        view.frame=CGRectMake(i%2*(WIDTH - 30)/2.0 + i%2*5, i/2*30, (WIDTH - 30)/2.0, 30);
        [_viewback2 addSubview:view];
        
        _lableR2=[[UILabel alloc] init];
        [_lableR2 sizeToFit];
        _lableR2.font=[UIFont systemFontOfSize:12.0];
        _lableR2.textColor=[UIColor blackColor];
        _lableR2.text=_rightArray[i];
        _lableR2.frame=CGRectMake((WIDTH-80)/4+5, 0, (WIDTH-30)/2-(WIDTH-80)/4, 30);
        [view addSubview:_lableR2];
    }
}






- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
